﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Utilities; 

namespace QuickUIT.Tests
{
    [TestClass]
    public class ValidationUtilityTests
    {
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ShouldThrowExceptionOnValidateArgumentNotNullForNullObject()
        {
            ValidationUtility.ValidateArgumentNotNull(null, "param");
        }

        [TestMethod]
        public void ShouldPassValidateArgumentNotNullForNonNullObject()
        {
            ValidationUtility.ValidateArgumentNotNull(1, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionOnValidateStringNotNullOrEmptyOrWhitespaceForNullString()
        {
            ValidationUtility.ValidateStringNotNullOrEmptyOrWhitespace(null, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionOnValidateStringNotNullOrEmptyOrWhitespaceForEmptyString()
        {
            ValidationUtility.ValidateStringNotNullOrEmptyOrWhitespace(String.Empty, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionOnValidateStringNotNullOrEmptyOrWhitespaceForWhitespaceString()
        {
            ValidationUtility.ValidateStringNotNullOrEmptyOrWhitespace("   ", "param");
        }

        [TestMethod]
        public void ShouldPassValidateStringNotNullOrEmptyOrWhitespaceForNormalString()
        {
            ValidationUtility.ValidateStringNotNullOrEmptyOrWhitespace("ABC", "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueGreaterThanForGreaterValue()
        {
            ValidationUtility.ValidateValueGreaterThan(1, 0, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionOnValidateValueGreaterThanForEqualValue()
        {
            ValidationUtility.ValidateValueGreaterThan(0, 0, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionOnValidateValueGreaterThanForLesserValue()
        {
            ValidationUtility.ValidateValueGreaterThan(-1, 0, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueGreaterThanOrEqualToForGreaterValue()
        {
            ValidationUtility.ValidateValueGreaterThanOrEqualTo(1, 0, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueGreaterThanOrEqualToForEqualValue()
        {
            ValidationUtility.ValidateValueGreaterThanOrEqualTo(0, 0, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldPassValidateValueGreaterThanOrEqualToForLesserValue()
        {
            ValidationUtility.ValidateValueGreaterThanOrEqualTo(-1, 0, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionValidateValueLessThanForGreaterValue()
        {
            ValidationUtility.ValidateValueLessThan(1, 0, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionOnValidateValueLessThanForEqualValue()
        {
            ValidationUtility.ValidateValueLessThan(0, 0, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueLessThanForLesserValue()
        {
            ValidationUtility.ValidateValueLessThan(-1, 0, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowExceptionOnValidateValueLessThanOrEqualToForGreaterValue()
        {
            ValidationUtility.ValidateValueLessThanOrEqualTo(1, 0, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueLessThanOrEqualToForEqualValue()
        {
            ValidationUtility.ValidateValueLessThanOrEqualTo(0, 0, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueLessThanOrEqualToForLesserValue()
        {
            ValidationUtility.ValidateValueLessThanOrEqualTo(-1, 0, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueInRangeInclusiveForInRangeValue()
        {
            ValidationUtility.ValidateValueInRangeInclusive(5, 0, 10, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueInRangeInclusiveForEqualMaxValue()
        {
            ValidationUtility.ValidateValueInRangeInclusive(10, 0, 10, "param");
        }

        [TestMethod]
        public void ShouldPassValidateValueInRangeInclusiveForEqualMinValue()
        {
            ValidationUtility.ValidateValueInRangeInclusive(0, 0, 10, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ShouldThrowExceptionOnValidateValueInRangeInclusiveForValueAboveMax()
        {
            ValidationUtility.ValidateValueInRangeInclusive(11, 0, 10, "param");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ShouldThrowExceptionOnValidateValueInRangeInclusiveForValueBelowMin()
        {
            ValidationUtility.ValidateValueInRangeInclusive(-1, 0, 10, "param");
        }
    }
}
